﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace fileWatcher
{
	public partial class Form1 : Form
	{
		private FileSystemWatcher _settingsWatcher;

		public Form1()
		{
			InitializeComponent();

			string aStr = "Truncate";
			FileInfo aFN = (FileInfo)Enum.Parse(
			  typeof(FileInfo), aStr);


			_settingsWatcher = new FileSystemWatcher();

			//watch 2 folders up from current folder
			_settingsWatcher.Path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..");
			//set file to monitor
			_settingsWatcher.Filter = "1.txt";

			//types of changes to watch
			_settingsWatcher.NotifyFilter = NotifyFilters.LastWrite;

			//events
			_settingsWatcher.Changed += new FileSystemEventHandler(ClientSettings_Changed);
			_settingsWatcher.Created += new FileSystemEventHandler(ClientSettings_Changed);


			//start watching
			StartWatch();
		}

		private void StartWatch()
		{
			_settingsWatcher.EnableRaisingEvents = true;
		}

		private void StopWatch()
		{
			_settingsWatcher.EnableRaisingEvents = false;
		}

		private void ClientSettings_Changed(object sender, FileSystemEventArgs e)
		{
			
		}
	}
}
